<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>


<form action="<?php echo site_url('adozioni/anagrafica/sostenitori/results') ?>" method="post" name="searchform" style="display: inline">
			 <?php echo __("Cerca Nome:", $module) ?> <input name="filter[nomecognome]" type="text" class="input" value="<?php if(isset($filter['nomecognome'])) echo $filter['nomecognome'] ?>" id="nomecognome">
			<?php if(isset($filter['liberi'])): ?>
          <input type='hidden' name='filter[liberi]' value="<?php  echo $filter['liberi'] ?>" />
          <input type='hidden' name='filter[categoria]' value="adozione" />
		    <?php else: ?>
			<select name="filter[attivo]">
			<option value="t" <?php if(!isset($filter['attivo']) || $filter['attivo'] == 't') echo " selected " ?>><?php echo __("Tutti", $module) ?></option>
			<option value="s" <?php if($filter['attivo'] == 's') echo " selected " ?>><?php echo __("Attivo", $module) ?></option>
			<option value="n" <?php if($filter['attivo'] == 'n') echo " selected " ?>><?php echo __("Non attivo", $module) ?></option>
			</select>
			<?php echo __("Categoria:", $module) ?>
			<select name="filter[categoria]">
				<option value=''><?php echo __("Tutti", $module) ?></option>
				<?php foreach($categorie as $c): ?>
					<option value="<?php echo strtolower($c['categoria']) ?>" <?php if(isset($filter['categoria']) && strtolower($c['categoria']) == $filter['categoria']) echo " selected "; ?>><?php echo $c['categoria']; ?></option>
				<?php endforeach; ?>
			</select>
			<?php endif; ?>
			  <input name="Submit2" type="submit" class="forminput" value="Cerca" style="cursor:hand" />
</form>
<?php if(count($filter) > 1): ?>
<form method='post' name='frmstampalettera' action="<?php echo site_url('adozioni/anagrafica/sostenitori/stampa') ?>" style="display: inline; ">
<input type="submit" name="stampalettera" value="<?php echo __("Stampa lettere / Buste / CCP", $module) ?>" />
</form>

<form method='post' name='salva_filtro' action="<?php echo site_url('adozioni/ricerca/ricerche/save') ?>" style="display: inline; ">
<label for="nome_ricerca"><?php echo __("Salva risultato", $module) ?></label>
<input type="hidden" name="controller" value="sostenitori" />
<input type="text" name="nome_ricerca" id="nome_ricerca" />
<input type="submit" name="salva_ricerca" value="<?php echo __("Ok", $module) ?>" />
</form>
<?php endif; ?>
<form method='post' name='frmexcel' action="<?php echo site_url('adozioni/anagrafica/sostenitori/results') ?>" style="display: inline; ">
<input type="submit" name="excel" value="<?php echo __("Esporta in Excel", $module) ?>" />
</form>
<?php if($this->session->userdata('search_anagrafica_sostenitori')): ?>
<a href="<?php echo site_url("adozioni/stampe/ricevute/fiscali") ?>" class="btn btn-success"><?php echo __("Stampa dichiarazioni fiscali", $module) ?></a>
<?php endif; ?>
</div>   
<table class="list" border="0" cellpadding="1" cellspacing="1">
  <tr class="titlemedium"> 
	<th width="3">#</th>
	<th height="25%" nowrap class="celeste bold"><?php echo anchor('adozioni/anagrafica/sostenitori/order_by/nomecognome',  __("Cognome e Nome", $module)) ?> </th>
	<th width="30%" align="center" class="celeste bold"><?php echo anchor('adozioni/anagrafica/sostenitori/order_by/categoria', __("Categoria", $module)) ?></th>
	<th width="20%" align="center" class="celeste bold"><?php echo __("Telefono", $module) ?></th>
	<th width="15%" align="center" class="celeste bold"><?php echo anchor('adozioni/anagrafica/sostenitori/order_by/data_inserimento', __("Inserito", $module)) ?></th>
	<?php if(isset($rows['0']['importo'])): ?>
	<th width="" align="center" class="celeste bold"><?php echo __("Importo", $module) ?></th>
	<?php endif; ?>
	<th width="" align="center" class="celeste bold"><?php echo __("Azioni", $module) ?></th>
  </tr>
  <?php if($rows): ?> 
  <?php $i=$start+1;foreach($rows as $row): ?>
    <?php if ($i % 2 != 0): $rowClass = 'odd'; else: $rowClass = 'even'; endif;?>
    <tr class="<?php echo $rowClass?>">
	<td><?php echo $i; ?></td>
	<td width="200" height="17" nowrap class="{CLASS} bold"><?php echo anchor('adozioni/anagrafica/sostenitori/show/' . $row['id'], $row['nomecognome']) ?></td>
	<td align="center" ><?php echo $row['categoria']; ?> </td>
	<td align="center" ><strong><?php echo $row['tel1']; ?> </strong></td>
	<td align="center" ><?php echo data($row['data_inserimento']); ?> </td>
	<?php if(isset($row['importo'])): ?>
	<td align="right" ><strong><?php echo format_euro($row['importo']); ?> </strong></td>
	<?php endif; ?>
	<td ><table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr align="center">
		  <td><?php echo anchor('adozioni/anagrafica/sostenitori/show/' . $row['id'], __("Visualizza", $module)) ?></td>
		  <td><?php echo anchor('adozioni/anagrafica/sostenitori/edit/' . $row['id'], __("Modifica", $module)) ?></td>
		  <td><?php echo anchor('adozioni/anagrafica/sostenitori/activate/no/' . $row['id'], __("Elimina", $module), array('onClick' => "return confirm('". __("Confermi Eliminazione ?", $module) . "')")) ?></td>
		  <td><?php echo anchor('adozioni/contabilita/offerte/edit/id_sostenitore/' . $row['id'], __("Nuova offerta", $module)) ?></td>
		</tr>
	  </table></td>
  </tr>
  <?php $i++;endforeach; ?>
  <?php endif;?>
</table>
<div class="noprint">
<script>
 document.form1.nomecognome.focus();
</script>
<?php echo $pager; ?>
</div>